<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>站点管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	$(document).ready(function() {
		layui.use(['laypage', 'form','table'], function(){
			var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
			form.render();
			var laypage = layui.laypage;
			laypage.render({elem:'pageDiv',
				count: ${page.count}, //数据总数，从服务端得到
				curr:${page.pageNo},
				limit:30,
				layout: ['prev', 'page', 'next', 'count'],
				jump: function(obj, first){
				//obj包含了当前分页的所有参数，比如：
				 // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
				 // console.log(obj.limit); //得到每页显示的条数
				
				//首次不执行
					if(!first){
						$("#firstPage").val(false);
						page(obj.curr,obj.limit);
					}
				}
			});
            //layui.table.init('contentTable');
		});
		var table = layui.table;
		table.init('siteTable',{limit:30});
	});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
	    	return false;
	    }
	</script>
</head>
<body>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		<ul class="layui-tab-title">
		<li class="layui-this"><a href="${ctx}/cms/site/">站点列表</a></li>
		<shiro:hasPermission name="cms:site:edit"><li><a href="${ctx}/cms/site/form">站点添加</a></li></shiro:hasPermission>
	</ul></div>
	<form:form id="searchForm" modelAttribute="site" action="${ctx}/cms/site/" method="post" class="layui-form">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<blockquote class="layui-elem-quote quoteBox">
		<div class="layui-inline">
			<label class="layui-form-label">名称：</label>
			<div class="layui-input-block">
				<form:input path="name" htmlEscape="false" maxlength="50" class="layui-input"/>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">状态：</label>
			<div class="layui-input-block">
				<c:forEach items="${fns:getDictList('del_flag')}" var="dict" varStatus="dictStatus">
					<span><input id="isShow${dict.value}"
						name="isShow" type="radio" value="${dict.value}"
						title="${dict.label}"></span>
				</c:forEach>
			</div>
		</div>
		<div class="layui-inline">
			<input id="btnSubmit" class="layui-btn search_btn" type="submit" value="查询"/>&nbsp;&nbsp;
		</div>
		</blockquote>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="layui-table" lay-filter="siteTable">
		<thead><tr>
			<th lay-data="{field:'siteName', minWidth:100}">名称</th>
			<th lay-data="{field:'siteTitle', minWidth:100}">标题</th>
			<th lay-data="{field:'siteDetail', minWidth:150}">描述</th>
			<th lay-data="{field:'keyWord', minWidth:100}">关键字</th>
			<th lay-data="{field:'them', minWidth:100}">主题</th>
			<shiro:hasPermission name="cms:site:edit">
			<th lay-data="{field:'villageNo', minWidth:110, fixed:'right'}">操作</th>
			</shiro:hasPermission>
		</tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="site">
			<tr>
				<td><a class="layui-blue" href="${ctx}/cms/site/form?id=${site.id}" title="${site.name}">${fns:abbr(site.name,40)}</a></td>
				<td>${fns:abbr(site.title,40)}</td>
				<td>${fns:abbr(site.description,40)}</td>
				<td>${fns:abbr(site.keywords,40)}</td>
				<td>${site.theme}</td>
				<shiro:hasPermission name="cms:site:edit"><td>
    				<a class="layui-btn layui-btn-xs" lay-event="edit"
    				 href="${ctx}/cms/site/form?id=${site.id}">修改</a>
					<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"
					 href="${ctx}/cms/site/delete?id=${site.id}${site.delFlag ne 0?'&isRe=true':''}" onclick="return confirmx('确认要${site.delFlag ne 0?'恢复':''}删除该站点吗？', this.href)" >${site.delFlag ne 0?'恢复':''}删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div id="pageDiv" class="pagination layui-elem-field layui-field-title">${page}</div>
</body>
</html>